
/****** Object:  StoredProcedure [usp_GetCustomersMasterByID]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_GetCustomersMasterByID]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_GetCustomersMasterByID];
GO

CREATE PROCEDURE [usp_GetCustomersMasterByID]
(
	@CustomerID int
)
AS
BEGIN
	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[CustomerID],
		[CustomeName],
		[Address],
		[ZipCode],
		[PhoneNo],
		[MobileNo],
		[LastModifiedUser],
		[LastModifiedDateTime]
	FROM [CustomersMaster]
	WHERE
		([CustomerID] = @CustomerID)

	SET @Err = @@Error

	RETURN @Err
END
GO


/****** Object:  StoredProcedure [usp_GetAllCustomersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_GetAllCustomersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_GetAllCustomersMaster];
GO

CREATE PROCEDURE [usp_GetAllCustomersMaster]
AS
BEGIN

	SET NOCOUNT ON
	DECLARE @Err int

	SELECT
		[CustomerID],
		[CustomeName],
		[Address],
		[ZipCode],
		[PhoneNo],
		[MobileNo],
		[LastModifiedUser],
		[LastModifiedDateTime]
	FROM [CustomersMaster]

	SET @Err = @@Error

	RETURN @Err
END
GO


/****** Object:  StoredProcedure [usp_UpdateCustomersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_UpdateCustomersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_UpdateCustomersMaster];
GO

CREATE PROCEDURE [usp_UpdateCustomersMaster]
(
	@CustomerID int,
	@CustomeName varchar(50),
	@Address varchar(MAX),
	@ZipCode varchar(6),
	@PhoneNo varchar(20) = NULL,
	@MobileNo varchar(10) = NULL,
	@LastModifiedUser int,
	@LastModifiedDateTime datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	UPDATE [CustomersMaster]
	SET
		[CustomeName] = @CustomeName,
		[Address] = @Address,
		[ZipCode] = @ZipCode,
		[PhoneNo] = @PhoneNo,
		[MobileNo] = @MobileNo,
		[LastModifiedUser] = @LastModifiedUser,
		[LastModifiedDateTime] = @LastModifiedDateTime
	WHERE
		[CustomerID] = @CustomerID


	SET @Err = @@Error


	RETURN @Err
END
GO




/****** Object:  StoredProcedure [usp_InsertCustomersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_InsertCustomersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_InsertCustomersMaster];
GO

CREATE PROCEDURE [usp_InsertCustomersMaster]
(
	@CustomerID int = NULL output,
	@CustomeName varchar(50),
	@Address varchar(MAX),
	@ZipCode varchar(6),
	@PhoneNo varchar(20) = NULL,
	@MobileNo varchar(10) = NULL,
	@LastModifiedUser int,
	@LastModifiedDateTime datetime
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	INSERT
	INTO [CustomersMaster]
	(
		[CustomeName],
		[Address],
		[ZipCode],
		[PhoneNo],
		[MobileNo],
		[LastModifiedUser],
		[LastModifiedDateTime]
	)
	VALUES
	(
		@CustomeName,
		@Address,
		@ZipCode,
		@PhoneNo,
		@MobileNo,
		@LastModifiedUser,
		@LastModifiedDateTime
	)

	SET @Err = @@Error

	SELECT @CustomerID = SCOPE_IDENTITY()

	RETURN @Err
END
GO


/****** Object:  StoredProcedure [usp_DeleteCustomersMaster]    Script Date: 3/17/2013 8:51:01 PM ******/
IF EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[usp_DeleteCustomersMaster]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
    DROP PROCEDURE [usp_DeleteCustomersMaster];
GO

CREATE PROCEDURE [usp_DeleteCustomersMaster]
(
	@CustomerID int
)
AS
BEGIN

	SET NOCOUNT OFF
	DECLARE @Err int

	DELETE
	FROM [CustomersMaster]
	WHERE
		[CustomerID] = @CustomerID
	SET @Err = @@Error

	RETURN @Err
END
GO

